﻿@{
    Layout = "_ContentLayout.cshtml";
}

@section headerBody {
    <h1>Create a package for your machine install</h1>
    <p class="lead">Perhaps you have a common collection of applications and settings that you would like to install on any machine you have to work on. You don't want to memorize complicated URLs.</p>
    <p class="lead"><span class="text-primary">Create and publish a package to create simple Boxstarter URLs!</span></p>
}


<h3>Step 1</h3>
<h4><span class="text-primary">Install Boxstarter</span></h4>
<p>If you have Chocolatey:</p>
<pre>CINST Boxstarter</pre>
<p>Otherwise, click on the download link at the top of this page and run the Setup.bat file. See <a href="InstallBoxstarter">Installing Boxstarter</a> for details.</p>

<h3>Step 2</h3>
<h4><span class="text-primary">Create your installer script</span></h4>
<p>Open your favorite text editor and compose your installer. Although this can contain any valid Powershell, you really do not need to know any Powershell to create your script. This could just be a collection of Boxstarter commands. Here is an example:</p>
<pre>
Set-ExplorerOptions -showHidenFilesFoldersDrives -showProtectedOSFiles -showFileExtensions
Enable-RemoteDesktop
Set-StartScreenOptions -EnableBootToDesktop
cinst fiddler4
cinst git-credential-winstore
cinst console-devel
cinst sublimetext2
cinst poshgit
cinst dotpeek
Install-WindowsUpdate -AcceptEula
</pre>
<p>These are just Chocolatey Install calls and Boxstarter commands. Save this to a file - name and location do not matter. For a complete list of Boxstarter commands available in a package, see <a href="~/WinConfig">Boxstarter WinConfig Commands</a> and <a href="~/CreatingPackages">Creating Packages</a> for details covering the creation of Chocolatey packages.</p>

<h3>Step 3</h3>
<h4><span class="text-primary">Invoke the Boxstarter shell</span></h4>
<img src="~/Images/shortcut.png">
<p>The Boxstarter install creates a shortcut to a shell that provides the easiest way to access Boxstarter commands especially if you are not familiar with Powershell. See <a href="~/UsingBoxstarter">Using Boxstarter Commands</a> for information about running Boxstarter in your own shell.</p>

<h3>Step 4</h3>
<h4><span class="text-primary">Convert your Script to a Package</span></h4>
<p>Lets assume the script was saved to c:\dev\script.ps1 and I wanted to name my package mwrock.DefaultInstall. Run this command:</p>
<pre>
 New-PackageFromScript -Source c:\dev\script.ps1 -PackageName mwrock.DefaultInstall
</pre>
<p>This creates a simple Chocolatey package and packs it to a .nupkg file.</p>

<h3>Step 5</h3>
<h4><span class="text-primary">Publish the Package</span></h4>
<p>You can publish your package to any feed you have access to. We will publish to the public Chocolatey feed. To do this you will need to <a href="https://chocolatey.org/account/Register">register</a> a free chocolatey account and obtain an API key. </p>
<p>Once you have a Chocolatey account and have followed the instructions on the Registration confirmation regarding setting your API key, you can use Chocolatey's cpush command to accomplish this:</p>
<pre>
 CPUSH (Join-Path $Boxstarter.LocalRepo mwrock.DefaultInstall.1.0.0.nupkg)
</pre>
<p>Boxstarter saves all packages to its LocalRepo property. Now cpush will find the .nupkg file and upload it to the Chocolatey feed. See <a href="~/PublishingPackages">Publishing Packages</a>for more details regarding package publishing and using different feeds.</p>

<h3>Step 6</h3>
<h4><span class="text-primary">Install the Package anywhere</span></h4>
<p>Using IE (or any other browser that has a click-once extension installed) or from a command line (if IE or a click-once enabled browser is your default browser) run:</p>
<pre>START http://boxstarter.org/package/mwrock.DefaultInstall</pre>

<p>Accept the prompts for installing the Boxstarter installer and running with administrative privileges. When the install begins, Boxstarter will ask for a password do that it can resume the installer in the event it needs to reboot.</p>
<p>There are other ways to install the package as well. You can even <a href="~/InstallingPackages#RemoteInstallations">install to a remote machine</a> or to an <a href="~/VMIntegration">Azure or Hyper-V VM with checkpointing support</a>.</p>
